package com.zch.date_;

import java.util.Calendar;

/**
 * 第二代日期类
 */
public class Calendar_ {
    public static void main(String[] args) {
        //构造器是protected修饰的，只能通过getInstance返回对象
        Calendar c1 = Calendar.getInstance();
        System.out.println(c1);
        System.out.println(c1.get(Calendar.YEAR)); //若不用c1.get，获得的是默认值
        System.out.println(c1.get(Calendar.MONTH) + 1); //月份从0开始计算
        System.out.println(c1.get(Calendar.DATE));
        System.out.println(c1.get(Calendar.HOUR));
        System.out.println(c1.get(Calendar.HOUR_OF_DAY)); //获取到24小时制的时间
        System.out.println(c1.get(Calendar.MINUTE));
        System.out.println(c1.get(Calendar.SECOND));
    }
}
